package com.lk.pet.customer.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/customer")
public class CustomerController {

    private static final Logger log = LoggerFactory.getLogger(CustomerController.class);

    @GetMapping("/process")
    public List<Map<String, Object>> getProcess(){
        RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
        Map<String, Object> customer = new HashMap<>();
        Integer processId=Integer.valueOf(runtimeMXBean.getName().split("@")[0]);
        log.info("#########process is {}",runtimeMXBean.getName());
        customer.put("process", runtimeMXBean.getName());
        customer.put("processId", processId);
        List<Map<String,Object>> ls = new ArrayList<>();
        ls.add(customer);
        return ls;
    }
}
